<?php
/**
 * Created by 1971599474@qq.com
 * User: zhixuan
 * Date: 2020/1/17
 * Time: 15:02
 */

namespace app\index\controller;
use app\common\model\Goods as GoodsModel;

class Integral extends Base
{

    public function index(){
        $where = [['is_on_sale','=',1],['exchange_integral','=',0]];

        $reCommendGoods = GoodsModel::getRecommendGoods($where,4);
        $params = array_filter(request()->param());
        $page = ! empty($params['page']) && $params['page'] >= 1 ? $params['page'] : 1;

        $where = [['is_on_sale','=',1],['exchange_integral','>',0]];
        //获取积分商品
        $condition = [
            'with'  => ['getShop'],
            'where' => $where,
            //'order' => ['id' => 'desc'],
            'field' => 'goods_id,goods_name,shop_price,original_img,goods_type,shop_id,exchange_integral',
            'paginate' => [
                'page' => $page,
                'query' => $params,
                //'list_rows'=>1,
            ],
        ];
        $goods = GoodsModel::getPageAll($condition);
        $this->assign(compact('reCommendGoods','goods'));
        return $this->fetch();
    }
}